package com.lottery.ruok.lottrey.ui.component;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.retrofitModule.response.GetWholeCategoryResponse;

import butterknife.BindView;
import butterknife.ButterKnife;
import glideHelp.GlideHelper;

public class HomeCPItemView extends BaseRelativeLayout {
    @BindView(R.id.iv_icon)
    ImageView iv_icon;
    @BindView(R.id.tv_title)
    TextView tv_title;
    @BindView(R.id.tv_content)
    TextView tv_content;
    @BindView(R.id.img_hot)
    ImageView img_hot;

    public HomeCPItemView(Context context) {
        super(context);
    }

    public HomeCPItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public HomeCPItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(Context context, AttributeSet attrs, int defStyleAttr) {

    }

    @Override
    protected void initView(Context context) {
        LayoutInflater.from(mContext).inflate(R.layout.view_item_home_cp, this);
        ButterKnife.bind(this, this);

    }

    @Override
    protected void load(Context context) {

    }

    public void setData(GetWholeCategoryResponse.ItemsBean data) {
        if (data != null) {
            tv_title.setText(data.getName());
            tv_content.setText(data.getDesc());
            if(data.getIs_hot() > 0){
                img_hot.setVisibility(VISIBLE);
            }else{
                img_hot.setVisibility(GONE);
            }
            GlideHelper.loadImage(mContext, data.getImage_url(), iv_icon);
        }
    }
}
